﻿using System;
using System.Threading;

namespace HCAD.CircularWorkingScaffoldAssistant.Component.Infrastructure
{
    public class SyncContextSwitcher<T>
    {
        private readonly SynchronizationContext ctx = SynchronizationContext.Current;

        public void Process(T msg)
        {
            if (ctx != null)
                ctx.Send(x => Result(msg), null);
            else
            {
                Result(msg);
            }
        }

        public Action<T> Result;
    }
}